home *** CD-ROM | disk | FTP | other *** search
- ==========================
- Ch 7 − Using extra indices
- ==========================
-
- The record data is stored in a file called Database inside the database’s
- application directory. The order of records within Database is determined by
- the order in which the records are entered. To access the records in a
- logical order we need one or more indices. Powerbase does have sorting
- facilities for sorting reports and validation tables, but data ordering is
- achieved mainly by the use of indices.
-
- The most important index is index 0. This is always called “PrimaryKey” and
- is created as part of the process of setting up a database (see 4.5). You
- will find the file PrimaryKey inside the database directory. Other,
- subsidiary, indices are stored in the database’s Indices directory and all
- have a large I on their icon. When a database is opened any indices in this
- directory will be loaded automatically. (Indices operate in memory − to
- achieve maximum speed − not from disc.) Changes to the database update the
- indices and closing the database (or quitting Powerbase itself) causes the
- updated indices to be written back to the disc.
-
- Note that the more indices you use the longer it takes to add and delete
- records or to make alterations to records which involve changing indices.
- The ideal situation might seem to be to have all fields indexed and, given a
- fast enough machine, a hard disc and a record structure with not very many
- fields, this might be feasible. Remember that fields which are repetitive
- (those which have only a few distinct values repeated throughout many
- records) do not index efficiently.
-
- Subsidiary indices can speed up report printing in some cases (see 3.12).
- When you enter a query Powerbase will see if a subsidiary index can be used
- with advantage and, if so, will go ahead and use it. To indicate that this
- is happening the number of the subsidiary index will appear in the small
- rectangle at the the top right of the query panel. For the speed-up to work
- the case button on the query panel must match the case-dependence of the
- index. This is a point easily overlooked!
-
- 7.1 Indexing a field
- ------------------------
- Click MENU over the required field and choose Create Index (Ctrl J) from the
- Field submenu. The Key structure window will appear with the tag of the
- field you clicked on in the first of the four Field icons. You may use the
- bump icons or pop-up menus to bring the tags of the other fields into view
- if you wish to base the index on more than one field. Enter the data in
- exactly the same way as when creating the primary key index (see 4.5) and
- click on Create. If the field is already indexed you will be warned of this
- and asked if you wish to overwrite the existing index. When indexing is
- complete you will see that the descriptor of the indexed field has changed
- from black to dark blue.
-
- If you click the “key” buttons on the keypad (Shift F4 and Shift F5) the red
- highlighting of the descriptor which indicates the current key moves from
- one indexed field to another. When you have a subsidiary key selected as the
- current key it works just like the primary key as regards browsing,
- searching and printing.
-
- There is nothing to stop you indexing one field whilst a subsidiary index
- based on another field is the currently-active one, thus producing what
- amounts to a sort within a sort.
-
- One button which was shaded when creating the primary key is the option
- switch Omit null keys. Although null primary keys aren’t allowed null
- subsidiary keys are and the default setting for this switch is therefore
- OFF. The field being indexed might in some cases be null most of the time
- and you want to index only the records in which it isn’t. If so, select the
- switch before clicking Create.
-
- The Index entry on the main menu leads to a submenu offering three choices.
- Show details (Ctrl K) displays the structure of the currently active key.
- Show files (Ctrl I) opens the Indices directory. Delete allows you to remove
- an index (after confirmation). The index file isn't actually deleted from
- Indices but simply renamed so that it has the prefix “Del_”. Such an index
- is no longer active and will not be loaded when the database is opened. You
- can, however, restore it by removing the prefix but it is only useful to do
- so if no records have been added to or removed from the database in the
- meantime.
-
- 7.2 Automatic saving of indices
- -----------------------------------
- Indices are written to disc when you close a database or quit Powerbase but,
- as long as the database remains open, they are in memory and therefore could
- be lost if the power fails or the computer is switched off. Occasional use
- of the keypad’s Force update button ensures that the disc copy of all
- indices is more or less up-to-date but you can automate the process if you
- wish. Choose Preferences from the iconbar menu, make the appropriate
- selection from the Save indices section of the Preferences window and click
- on Accept. You may make Powerbase save the indices at regular intervals or
- simply warn you to do so.
-
- - 43 -